package com.googlecode.dgwt.client.dijit.view.base;

import com.googlecode.dgwt.client.dijit.View;
import com.googlecode.dgwt.client.dijit.Widget;
import com.googlecode.dgwt.client.dijit.base.FocusWidget;
import com.googlecode.dgwt.client.dijit.base.manager.PanelFocusManager;

/**
 * Base class for views that extends {@link FocusWidget}.
 * 
 * @author wellsantos@wellsantos.com
 * @since 0.01
 */
public abstract class FocusViewBase extends FocusWidget implements View {

    protected FocusViewBase(boolean ready) {
        super(ready);
    }
    
    @Override
    protected abstract void buildRendering();

    @Override
    protected PanelFocusManager getFocusManager() {
        return PanelFocusManager.get();
    }

    @Override
    public Widget getParent() {
        return (Widget) super.getParent();
    }
    
    @Override
    public String getName() {
        return getWidgetId();
    }

    @Override
    public Widget getWidget() {
        return this;
    }

    @Override
    public boolean equals(Object obj) {
        if (this == obj){
            return true;
        }
        if (obj instanceof View){
            obj = ((View) obj).getWidget();
        }
        return getWidget() == obj;
    }

}
